public class PloInput {

	private Ids ids;
	
	public PloInput (Tokens tokens) {
		this.parse(tokens);
	}

	public void parse(Tokens tokens) {
		// check for "read"
		if(tokens.getToken() != 10){
			System.err.println("Keyword \"read\" expected before token: " + tokens.idName());
			System.exit(0);
		}
		tokens.skipToken();
		this.ids = new Ids(tokens);
		// check for ';'
		if(tokens.getToken() != 12){
			System.err.println("read commands must end with a semicolon");
			System.err.println(0);
		}
		tokens.skipToken();
	}

	public void runInput() {
		String currentID = ids.getCurrentID();
		if (!Main.inputData.isEmpty()) {
			int value = Main.inputData.remove();
			Id.updateID(currentID, value);	
		} else {
			System.err.println("Not enough integers in data file for READ");
			System.exit(0);
		}
	}
}

